package com.uflower.user.service.impl;

import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.uflower.common.utils.PageUtils;
import com.uflower.common.utils.Query;

import com.uflower.user.dao.ReceiveAddressDao;
import com.uflower.user.entity.ReceiveAddressEntity;
import com.uflower.user.service.ReceiveAddressService;
import org.springframework.util.MultiValueMap;


@Service("receiveAddressService")
public class ReceiveAddressServiceImpl extends ServiceImpl<ReceiveAddressDao, ReceiveAddressEntity> implements ReceiveAddressService {


    @Override
    public void save(Long uid, String name, String phone, String province, String city, String region, String detailAddress) {
        ReceiveAddressEntity addressEntity= new ReceiveAddressEntity(uid,name,phone,province,city,region,detailAddress);
        this.save(addressEntity);
    }

    @Override
    public List<ReceiveAddressEntity> getAddress(Long userId) {
        List<ReceiveAddressEntity> address = baseMapper
                .selectList(new QueryWrapper<ReceiveAddressEntity>().eq("uid", userId));
        return address;
    }




    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<ReceiveAddressEntity> page = this.page(
                new Query<ReceiveAddressEntity>().getPage(params),
                new QueryWrapper<ReceiveAddressEntity>()
        );

        return new PageUtils(page);
    }

}